/**
 * 
 * 上下文对象单例对象
 *
 */
class Context extends egret.EventDispatcher {

    private static instance: Context = null;

    public root: eui.UILayer;

    private _stage: egret.Stage = egret.MainContext.instance.stage;

    private _commonViewManager: CommonViewManager = new CommonViewManager();

    public constructor() {
        super();
    }
    /**
     * 舞台
     */ 
    public get stage(): egret.Stage {
        return this._stage;
    }
    /**
     * 通用view管理器
     */ 
    public get commonViewManager(): CommonViewManager {
        return this._commonViewManager;
    }

    public static getInstance(): Context {
        if(this.instance == null) {
            this.instance = new Context();
        }
        return this.instance;
    }
    
    /**
    * 获取游戏的高度
    * @returns {number}
    */
    public getHeight(): number {
        return this.stage.stageHeight;
    }

    /**
     * 获取游戏宽度
     * @returns {number}
     */
    public getWidth(): number {
        return this.stage.stageWidth;
    }
    
    /**
     * 指定此对象的子项以及子孙项是否接收鼠标/触摸事件
     * @param value
     */
    public setTouchChildren(value: boolean): void {
        this.stage.touchChildren = value;
    }
    
    /**
     * 设置同时可触发几个点击事件，默认为2
     * @param value
     */
    public setMaxTouches(value: number): void {
        this.stage.maxTouches = value;
    }
    
    /**
     * 设置帧频
     * @param value
     */
    public setFrameRate(value: number): void {
        this.stage.frameRate = value;
    }
    
    /**
     * 设置适配方式
     * @param value
     */
    public setScaleMode(value: string): void {
        this.stage.scaleMode = value;
    }



}
